#ifndef LOOP_THREAD_H_
#define LOOP_THREAD_H_

#include "Thread.h"

class LoopThread : public Thread
{
    //this is added to ensure that m_tActive is only false when the thread has
    //actually returned from process
private: 
    bool m_stopRequested;
public:
    LoopThread() : m_stopRequested(false) {}

    //run untill someone calls vStop.
    //mark tActive as false only when done
    virtual void vRun()
    {
        while(!m_stopRequested)
            vProcess();
        m_tActive = false;
    }
    virtual void vStop()
    {
        m_stopRequested = true;
    }
    virtual void vPause()
    {
        assert(0);
        //not supported, try a conditional thread
    }
    virtual void vResume()
    {
        vPause();
    }
};

#endif // LOOP_THREAD_H_